package com.bestdreamer.thread_join;

public class Demo1ThreadA extends Thread {

    private final Demo1ThreadB threadB;

    public Demo1ThreadA(Demo1ThreadB threadB){
        super();
        this.threadB = threadB;
    }

    @Override
    public void run() {
        try{
            synchronized (threadB){
                threadB.start();
                Thread.sleep(1000);
                System.out.println("threadB 已启动，准备执行 join 方法");
//                threadB.join();
                System.out.println("执行了 Join 方法");
//                for(int i = 0; i < Integer.MAX_VALUE; i++){
//                    String newString = new String();
//                    Math.random();
//                }
            }
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
}
